﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using LPV_POS.In;
using System.Resources;
using System.Globalization;

namespace LPV_POS.mh_pos
{
    public partial class mh_banhang7_GiaBan : DevExpress.XtraEditors.XtraForm
    {
        CultureInfo culture;
        string MaHH = "";

        #region "Muti language"

        private void SetLanguage_banhang(string cultureName)
        {
            try
            {
                culture = CultureInfo.CreateSpecificCulture(cultureName);
                ResourceManager rm = new ResourceManager("LPV_POS.Muti_language.MyResource", typeof(mh_banhang7_GiaBan).Assembly);
                bton_thuchien_1.Text = rm.GetString("dongy", culture);
                this.col_giaTien.Caption = rm.GetString("giaban", culture);
                this.col_giaTen.Caption = rm.GetString("stt", culture);
                lbel_tencongty.Text = rm.GetString("chongiasanpham", culture);
               
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Note");
            }

        }

        #endregion
        public mh_banhang7_GiaBan(string _MaHH)
        {
            MaHH = _MaHH;
            InitializeComponent();
        }

        private void mh_banhang7_GiaBan_Load(object sender, EventArgs e)
        {
            cpublic ocpublic = new cpublic();
            string str_lang = ocpublic.Registry_Get("mh_main_lang");
            if (str_lang == "")
                str_lang = "vi-VN";
            SetLanguage_banhang(str_lang);

            DataTable DMHH = new thuvien().SP_SelectDataTable("sp_DM_HH", new string[] { "@flag", "@OBJID" }, new object[] { 3, MaHH });
            gridControl1.DataSource = DMHH;
            if (DMHH.Rows.Count == 0)
            {
                LPV_POS.Module.MessageBox_LPV.Show("Món hàng nhập giá");
                this.Dispose();
            }
        }



        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Dispose();
        }

        private void btnThucHien_Click(object sender, EventArgs e)
        {
            DataRow dr = gridView1.GetDataRow(gridView1.FocusedRowHandle);

            float.TryParse(dr["GIA"] + "", out fso);

            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            DataRow drv = gridView1.GetDataRow(gridView1.FocusedRowHandle);
            if (drv != null)
            {
                string o2 = drv.ToString();
                string DM_BAN_MA2 = drv["STT_GIA"] + "";
                string sDenBan_Ten = drv["GIA"] + "";
            }
        }
        float fso = 0;
        public float ShowForm()
        {
            this.ShowDialog();

            return fso;
        }
    }
}